function loadTiles( map )
	local tiles = {}
	local x = 0
	local y = 0
	-- load tiles
	for i = 1, 30 do
		y = math.floor((i - 1) / 5)
		x = (i - 1) % 5
		tiles[i] = {
			image = love.graphics.newQuad( x * map.tilewidth, y * map.tileheight, map.tilewidth, map.tileheight, sheet:getWidth(), sheet:getHeight() ),
			collisionMap = newCollisionMap( "img/omegasectortiles.png", x * map.tilewidth, y * map.tileheight )
		}
	end
	return tiles
end

function loadMap()
	local map_temp = require("level1")
	local data = {}
	local i = 1
	
	--setup data
	for x = 1, map_temp.width do
		data[x] = {}
		for y = 1, map_temp.height do
			data[x][y] = 0
		end
	end
	
	--populate data
	for y = 1, map_temp.height do
		for x = 1, map_temp.width do
			data[x][y] = {
				key = map_temp.layers[1].data[i],
				screenx = (x - 1) * map_temp.tilewidth,
				screeny = (y - 1) * map_temp.tileheight
			}
			i = i + 1
		end
	end
	
	map_temp.layers[1].data = data
	return map_temp
end

function loadCanvas( map, sheet, sprites )
	local canvas = love.graphics.newCanvas( )
	
	canvas:renderTo(function()
		for x = 1, map.width do 
			for y = 1, map.height do
				local tile = map.layers[1].data[x][y]
				love.graphics.rectangle( "line", (x - 1) * map.tilewidth, (y - 1) * map.tileheight, map.tilewidth, map.tileheight )
				if tile.key > 0 then
					love.graphics.drawq( sheet, sprites[tile.key].image, tile.screenx, tile.screeny, 0, 1, 1 )
					--love.graphics.print(tostring(num), (x - 1) * map.tilewidth, (y - 1) * map.tileheight)
				end
			end
		end
	end)
	return canvas
end